<!DOCTYPE html>
<html>
    <head>
        <title>Promise组件</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <script src="../avalon.js">

        </script>
        <script src="../highlight/shCore.js">

        </script>
        <script>
            require(["mmPromise/mmPromise", "domReady!"], function() {
                var _resolve, _reject
                var originalPromise = new Promise(function(resolve, reject) {
                    _resolve = resolve
                    _reject = reject
                });
                var promise = new Promise(function(resolve) {
                    resolve(originalPromise);
                });
                promise.then(function(value) {
                    vmodel.array.push("跑到这里来了");
                }, function(reason) {
                    vmodel.array.push(reason)
                    vmodel.array.push(reason === "original reason");

                });
                var vmodel = avalon.define("test", function(vm) {
                    vm.click = function() {
                        _reject("original reason")
                    }
                    vm.array = ["准备开始"]
                })
                avalon.scan()
            })
        </script>
    </head>
    <body ms-controller="test">
        <ul>
            <li ms-repeat="array">{{el}}</li>
        </ul>
        <p><button ms-click="click" type="button">点我开始</button></p>
        <pre class="brush:javascript;gutter:false;toolbar:false;">
            require(["mmPromise/mmPromise", "ready!"], function() {
                var _resolve, _reject
                var originalPromise = new Promise(function(resolve, reject) {
                    _resolve = resolve
                    _reject = reject
                });
                var promise = new Promise(function(resolve) {
                    resolve(originalPromise);
                });
                promise.then(function(value) {
                    vmodel.array.push("跑到这里来了");
                }, function(reason) {
                    vmodel.array.push(reason)
                    vmodel.array.push(reason === "original reason");

                });
                var vmodel = avalon.define("test", function(vm) {
                    vm.click = function() {
                        _reject("original reason")
                    }
                    vm.array = ["准备开始"]
                })
                avalon.scan()
            })
        </pre>
    </body>
</html>

